<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport"
          content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
    <title></title>
    <script src="../js/Cesium/1.83/Cesium.js"></script>
    <script src="../js/require.js"></script>
    <script src="./js/requireConfig.js"></script>
    <link rel="stylesheet" href="../js/Cesium/1.83/Widgets/widgets.css">
    <link rel="stylesheet" href="../css/common.css">

    <script>

        require([
            "uMap/uMap"
            , "uEarth/uEarth"
            , "mhjs/mhjs"
            , "App/UI/Layer"
        ], function (
            uMap
            , uEarth
            , mhjs
            , Layer
        ) {

            var earth = new uMap.Earth({
                objectOption: {
                    "container": "uMapApp_earthContainer"
                }
            });

            var debug = {};
            debug.transformPanel = new uMap.TransformPanel({
                "earth"     : earth,
                "title"     : "模型位置调整",
                "showClose" : true,
                "showSubmit": true,
                "submitText": "复制变形参数到剪贴板"
            });

            debug.transformPanel.on("submit", function (panel) {
                uMap.Clipboard(panel.transform.value);
            });

            debug.transformPanel.hide();
            $("body").append(debug.transformPanel.dom);

            //地球设置
            earth.scene.globe.depthTestAgainstTerrain = true;
            earth.scene.postProcessStages.fxaa.enabled = false;

            //固定光照
            earth.clock.currentTime = uEarth.JulianDate.fromDate(new Date("2020/01/01 10:00:00"));
            earth.clock.clockRange = uEarth.ClockRange.CLAMPED;
            earth.clock.shouldAnimate = false;

            var globeImagery = new Layer({
                app       : {
                    earth: earth
                },
                dataSource: {
                    "name"        : "GLOBE",
                    "title"       : "周边环境影像",
                    "type"        : "UrlTemplateImageryDataSource",
                    "url"         : "https://t{s}.tianditu.gov.cn/DataServer?T=img_w&x={x}&y={y}&l={z}",
                    "subdomains"  : ["0", "1", "2", "3", "4", "5", "6", "7"],
                    "tilingScheme": "3857",
                    "token"       : {
                        "key"  : "tk",
                        "value": "6034bdc779b72e554e4a3ba66f558b1d"
                    },
                    "maxLevel"    : 17
                }
            });

            globeImagery.open();

            var overlayImagery = new Layer({
                app       : {
                    earth: earth
                },
                dataSource: {
                    "name"        : "GLOBE_OVERLAY",
                    "title"       : "周边环境标注",
                    "type"        : "UrlTemplateImageryDataSource",
                    "url"         : "https://t{s}.tianditu.gov.cn/DataServer?T=cia_w&x={x}&y={y}&l={z}",
                    "subdomains"  : ["0", "1", "2", "3", "4", "5", "6", "7"],
                    "tilingScheme": "3857",
                    "token"       : {
                        "key"  : "tk",
                        "value": "6034bdc779b72e554e4a3ba66f558b1d"
                    },
                    "maxLevel"    : 17
                }
            });

            overlayImagery.open();

            var OPModelTileSet = new uMap.ObliquePhotographyModelPrimitive({
                objectOption: {
                    "url": "http://umap.earth:8084/DCHD08/G502022/8587/3DTILES/tileset.json"
                }
            });

            OPModelTileSet.on("loaded", function (tileSet) {

                // earth.camera.lookAt(
                //     tileSet.boundingSphere.center,
                //     new uEarth.HeadingPitchRange(
                //         uEarth.Math.toRadians(0), uEarth.Math.toRadians(-45), 400
                //     )
                // );

                earth.camera.flyToBoundingSphere(
                    tileSet.boundingSphere
                );

            });

            earth.scene.primitives.add(OPModelTileSet.object);

            var zhs = [
                {
                    "stakeNum" : "K85",
                    "position" : {
                        "longitude": 120.64428605345418,
                        "latitude" : 31.041213167658988,
                        "height"   : 12.401318455604741
                    },
                    "direction": "U"
                },
                {
                    "stakeNum" : "K85+100",
                    "position" : {
                        "longitude": 120.643241341699,
                        "latitude" : 31.04112970821233,
                        "height"   : 12.305838477856907
                    },
                    "direction": "U"
                },
                {
                    "stakeNum" : "K85+200",
                    "position" : {
                        "longitude": 120.64219717866268,
                        "latitude" : 31.04103271337137,
                        "height"   : 12.764133774685263
                    },
                    "direction": "U"
                },
                {
                    "stakeNum" : "K85+300",
                    "position" : {
                        "longitude": 120.64115483903188,
                        "latitude" : 31.040924483155546,
                        "height"   : 13.287754041742561
                    },
                    "direction": "U"
                },
                {
                    "stakeNum" : "K85+400",
                    "position" : {
                        "longitude": 120.64011445303441,
                        "latitude" : 31.04080293884057,
                        "height"   : 13.671010994653379
                    },
                    "direction": "U"
                },
                {
                    "stakeNum" : "K85+500",
                    "position" : {
                        "longitude": 120.63907629436653,
                        "latitude" : 31.040667988310602,
                        "height"   : 14.185147314590242
                    },
                    "direction": "U"
                },
                {
                    "stakeNum" : "K85+600",
                    "position" : {
                        "longitude": 120.63803996649722,
                        "latitude" : 31.040523145995046,
                        "height"   : 14.188109583653636
                    },
                    "direction": "U"
                },
                {
                    "stakeNum" : "K85+700",
                    "position" : {
                        "longitude": 120.63700642618173,
                        "latitude" : 31.040364450619705,
                        "height"   : 13.935766736418348
                    },
                    "direction": "U"
                },
                {
                    "stakeNum" : "K85+800",
                    "position" : {
                        "longitude": 120.63597537685055,
                        "latitude" : 31.040193768604322,
                        "height"   : 13.418772358095072
                    },
                    "direction": "U"
                },
                {
                    "stakeNum" : "K85+900",
                    "position" : {
                        "longitude": 120.63494721826513,
                        "latitude" : 31.04001069157519,
                        "height"   : 12.752799767307893
                    },
                    "direction": "U"
                },
                {
                    "stakeNum" : "K86",
                    "position" : {
                        "longitude": 120.63392187533326,
                        "latitude" : 31.039815623006756,
                        "height"   : 12.565901628405713
                    },
                    "direction": "U"
                },
                {
                    "stakeNum" : "K86+100",
                    "position" : {
                        "longitude": 120.6329000758543,
                        "latitude" : 31.03960700798925,
                        "height"   : 12.404020667226279
                    },
                    "direction": "U"
                },
                {
                    "stakeNum" : "K86+200",
                    "position" : {
                        "longitude": 120.63188227557042,
                        "latitude" : 31.039385988696658,
                        "height"   : 12.307387747380417
                    },
                    "direction": "U"
                },
                {
                    "stakeNum" : "K86+300",
                    "position" : {
                        "longitude": 120.63086762372018,
                        "latitude" : 31.039154483724467,
                        "height"   : 12.32255330987528
                    },
                    "direction": "U"
                },
                {
                    "stakeNum" : "K86+400",
                    "position" : {
                        "longitude": 120.629855996924,
                        "latitude" : 31.038912039532107,
                        "height"   : 12.28230442807138
                    },
                    "direction": "U"
                },
                {
                    "stakeNum" : "K86+500",
                    "position" : {
                        "longitude": 120.62884191487827,
                        "latitude" : 31.03867559343181,
                        "height"   : 12.204865836506933
                    },
                    "direction": "U"
                },
                {
                    "stakeNum" : "K86+600",
                    "position" : {
                        "longitude": 120.62782742759083,
                        "latitude" : 31.038439523058077,
                        "height"   : 12.240931043006174
                    },
                    "direction": "U"
                },
                {
                    "stakeNum" : "K86+700",
                    "position" : {
                        "longitude": 120.62684983796248,
                        "latitude" : 31.038103512549977,
                        "height"   : 12.396378487970466
                    },
                    "direction": "U"
                },
                {
                    "stakeNum" : "K86+800",
                    "position" : {
                        "longitude": 120.62585594943548,
                        "latitude" : 31.037811533721175,
                        "height"   : 12.575472371410926
                    },
                    "direction": "U"
                },
                {
                    "stakeNum" : "K86+900",
                    "position" : {
                        "longitude": 120.62486801228889,
                        "latitude" : 31.037506046696084,
                        "height"   : 12.748718129023658
                    },
                    "direction": "U"
                },
                {
                    "stakeNum" : "K87",
                    "position" : {
                        "longitude": 120.62386348615138,
                        "latitude" : 31.037236775475066,
                        "height"   : 12.92335308993733
                    },
                    "direction": "U"
                },{
                    "stakeNum" : "K85",
                    "position" : {
                        "longitude": 120.6443167173448,
                        "latitude" : 31.04091713988947,
                        "height"   : 12.444470065587547
                    },
                    "direction": "D"
                },
                {
                    "stakeNum" : "K85+100",
                    "position" : {
                        "longitude": 120.64327522126973,
                        "latitude" : 31.04083437142784,
                        "height"   : 12.341146198754052
                    },
                    "direction": "D"
                },
                {
                    "stakeNum" : "K85+200",
                    "position" : {
                        "longitude": 120.64223658815165,
                        "latitude" : 31.040737281088305,
                        "height"   : 12.747806275207573
                    },
                    "direction": "D"
                },
                {
                    "stakeNum" : "K85+300",
                    "position" : {
                        "longitude": 120.6411991720064,
                        "latitude" : 31.04062858418148,
                        "height"   : 13.258690681482864
                    },
                    "direction": "D"
                },
                {
                    "stakeNum" : "K85+400",
                    "position" : {
                        "longitude": 120.64016357201572,
                        "latitude" : 31.04050808663564,
                        "height"   : 13.597910836571561
                    },
                    "direction": "D"
                },
                {
                    "stakeNum" : "K85+500",
                    "position" : {
                        "longitude": 120.63913008282765,
                        "latitude" : 31.040374304512202,
                        "height"   : 13.996498487924955
                    },
                    "direction": "D"
                },
                {
                    "stakeNum" : "K85+600",
                    "position" : {
                        "longitude": 120.63809924709832,
                        "latitude" : 31.040225862582233,
                        "height"   : 14.244121245235617
                    },
                    "direction": "D"
                },
                {
                    "stakeNum" : "K85+700",
                    "position" : {
                        "longitude": 120.63706965381361,
                        "latitude" : 31.040070878182064,
                        "height"   : 13.871115356590181
                    },
                    "direction": "D"
                },
                {
                    "stakeNum" : "K85+800",
                    "position" : {
                        "longitude": 120.63604327051503,
                        "latitude" : 31.039901125847372,
                        "height"   : 13.439950551638333
                    },
                    "direction": "D"
                },
                {
                    "stakeNum" : "K85+900",
                    "position" : {
                        "longitude": 120.63501977259494,
                        "latitude" : 31.039718881725776,
                        "height"   : 12.773811077518529
                    },
                    "direction": "D"
                },
                {
                    "stakeNum" : "K86",
                    "position" : {
                        "longitude": 120.63399929402206,
                        "latitude" : 31.03952505133489,
                        "height"   : 12.533362473937357
                    },
                    "direction": "D"
                },
                {
                    "stakeNum" : "K86+100",
                    "position" : {
                        "longitude": 120.6329829171296,
                        "latitude" : 31.039316292816434,
                        "height"   : 12.339304723605734
                    },
                    "direction": "D"
                },
                {
                    "stakeNum" : "K86+200",
                    "position" : {
                        "longitude": 120.63196891938458,
                        "latitude" : 31.03909723171197,
                        "height"   : 12.75324741985501
                    },
                    "direction": "D"
                },
                {
                    "stakeNum" : "K86+300",
                    "position" : {
                        "longitude": 120.63095952081088,
                        "latitude" : 31.03886326290699,
                        "height"   : 12.939763711211706
                    },
                    "direction": "D"
                },
                {
                    "stakeNum" : "K86+400",
                    "position" : {
                        "longitude": 120.62995893872045,
                        "latitude" : 31.038603904306683,
                        "height"   : 12.247939406934245
                    },
                    "direction": "D"
                },
                {
                    "stakeNum" : "K86+500",
                    "position" : {
                        "longitude": 120.62896271403753,
                        "latitude" : 31.03833335144777,
                        "height"   : 12.184360498391413
                    },
                    "direction": "D"
                },
                {
                    "stakeNum" : "K86+600",
                    "position" : {
                        "longitude": 120.62797060099875,
                        "latitude" : 31.03805074040297,
                        "height"   : 12.204510598480926
                    },
                    "direction": "D"
                },
                {
                    "stakeNum" : "K86+700",
                    "position" : {
                        "longitude": 120.62695890169785,
                        "latitude" : 31.03782091060852,
                        "height"   : 12.363099879953307
                    },
                    "direction": "D"
                },
                {
                    "stakeNum" : "K86+800",
                    "position" : {
                        "longitude": 120.6259704683525,
                        "latitude" : 31.03752957018851,
                        "height"   : 12.499397627280175
                    },
                    "direction": "D"
                },
                {
                    "stakeNum" : "K86+900",
                    "position" : {
                        "longitude": 120.62498730693817,
                        "latitude" : 31.037224195491707,
                        "height"   : 12.668161437002857
                    },
                    "direction": "D"
                },
                {
                    "stakeNum" : "K87",
                    "position" : {
                        "longitude": 120.6240335206847,
                        "latitude" : 31.03685339590553,
                        "height"   : 12.761393707879414
                    },
                    "direction": "D"
                }
            ];

            $.each(zhs, function (i, zh) {

                var marker = new uMap.Entity({
                    objectOption: {
                        position: zh.position,
                        point   : new uMap.PointGraphic({
                            objectOption: {
                                color                     : ["#fff"]
                                , disableDepthTestDistance: 0
                            }
                        }),
                        label   : new uMap.LabelGraphic({
                            objectOption: {
                                text                      : zh.stakeNum
                                , verticalOrigin          : "BOTTOM"
                                , pixelOffset             : [0, -10]
                                , disableDepthTestDistance: Number.POSITIVE_INFINITY
                            }
                        })
                    }
                });
                earth.entities.add(marker.object);

            });


        });
    </script>

</head>
<body>
<div id="uMapApp_earthContainer" class="uMapApp_earthContainer"></div>
</body>
</html>